package org.btik.light.mobile.common.handler.nbi;

import android.view.View;
import org.btik.light.mobile.common.handler.DevBinder;
import org.btik.light.mobile.meta.mo.DefaultDevMo;

import java.util.function.Consumer;

/**
 * @author lustre
 * @since 2023/4/30 15:43
 */
public class NbiController implements Consumer<View> , DevBinder {
    protected RawNbiCommand rawNbiCommand;

    @Override
    public void accept(View view) {
        NbiAgent.send(rawNbiCommand);
    }

    public NbiController(byte[] rawCommand) {
        rawNbiCommand = new RawNbiCommand(rawCommand);
    }

    @Override
    public void bind(DefaultDevMo devMo) {
        String sn = devMo.getSn();
        rawNbiCommand.setTarget(sn);
    }
}
